home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / eos / sun-eos-menubar.el.z / sun-eos-menubar.el
Encoding:
Text File  |  1998-05-21  |  18.2 KB  |  556 lines

  1. ;;; sun-eos-menu.el --- Implements the XEmacs/SPARCworks menubar
  2.  
  3. ;; Copyright (C) 1995  Sun Microsystems, Inc.
  4.  
  5. ;; Maintainer:    Eduardo Pelegri-Llopart <eduardo.pelegri-llopart@Eng.Sun.COM>
  6. ;; Author:      Eduardo Pelegri-Llopart <eduardo.pelegri-llopart@Eng.Sun.COM>
  7.  
  8. ;; Keywords:    SPARCworks EOS Era on SPARCworks menubar
  9.  
  10. ;;; Commentary:
  11. ;; This file contains functions that populate a SPARCworks menu
  12. ;; Please send feedback to eduardo.pelegri-llopart@eng.sun.com
  13.  
  14. ;;; Code:
  15.  
  16. (require 'eos-common "sun-eos-common")
  17.  
  18. (defun eos::toggle-sbrowser-selected-frame ()
  19.   ;; Toggle whether this frame is selected for SBrowser
  20.   (interactive)
  21.   (if (equal eos::sbrowser-frame (selected-frame))
  22.       (eos::select-sbrowser-frame nil)
  23.     (eos::select-sbrowser-frame (selected-frame)))
  24.   )
  25.  
  26. (defun eos::toggle-debugger-selected-frame ()
  27.   ;; Toggle whether this frame is selected for Debugger
  28.   (interactive)
  29.   (if (equal eos::debugger-frame (selected-frame))
  30.       (eos::select-debugger-frame nil)
  31.     (eos::select-debugger-frame (selected-frame)))
  32.   )
  33.  
  34. (defvar eos::long-menu
  35.   '(
  36.     ["Read and Execute a Dbx Command" eos::dbx-cmd (not (eq eos::key-mode 'none))]
  37.     ["Run" eos::run (not (eq eos::key-mode 'none))]
  38.     ["Fix" eos::fix (not (eq eos::key-mode 'none))]
  39.     "-----"
  40.     ["Print" eos::print (not (eq eos::key-mode 'none))]
  41.     ["Print *" eos::print* (not (eq eos::key-mode 'none))]
  42.     ["Dismiss Print" eos::dismiss-print-frame (not (eq eos::key-mode 'none))]
  43.     "-----"
  44.     ["Continue" eos::cont (not (eq eos::key-mode 'none))]
  45.     ["Stop" eos::stop-at (not (eq eos::key-mode 'none))]
  46.     ["Clear" eos::clear-at (not (eq eos::key-mode 'none))]
  47.     ["Next" eos::next (not (eq eos::key-mode 'none))]
  48.     ["Step" eos::step (not (eq eos::key-mode 'none))]
  49.     ["Step Up" eos::step-up (not (eq eos::key-mode 'none))]
  50.     ["Continue To" eos::cont-to (not (eq eos::key-mode 'none))]
  51.     "-----"
  52.     ["Stack Up" eos::up (not (eq eos::key-mode 'none))]
  53.     ["Stack Down" eos::down (not (eq eos::key-mode 'none))]
  54.     "-----"
  55.     ("Start Tool and Enable Frame"
  56.      ["Debugger" eos::start-debugger t]
  57.      ["Dbx" eos::start-dbx t]
  58.      ["SBrowser" eos::start-sbrowser t]
  59.     )
  60.     "-----"
  61.     ["Enable Frame for SBrowser"
  62.      eos::toggle-sbrowser-selected-frame
  63.      :style toggle
  64.      :selected (equal eos::sbrowser-frame
  65.               (selected-frame))]
  66.     ["Enable Frame for Debugger and Dbx"
  67.      eos::toggle-debugger-selected-frame
  68.      :style toggle
  69.      :selected (equal eos::debugger-frame
  70.               (selected-frame))]
  71.     "-----"
  72.     ["News..." eos::sw-news t]
  73.     )
  74.   )
  75.  
  76. (defvar eos::short-menu
  77.   '(
  78.     ("Start Tool and Enable Frame"
  79.      ["Debugger" eos::start-debugger t]
  80.      ["Dbx" eos::start-dbx t]
  81.      ["SBrowser" eos::start-sbrowser t]
  82.     )
  83.     "-----"
  84.     ["Enable Frame for SBrowser"
  85.      eos::toggle-sbrowser-selected-frame
  86.      :style toggle
  87.      :selected (equal eos::sbrowser-frame
  88.               (selected-frame))]
  89.     ["Enable Frame for Debugger and Dbx"
  90.      eos::toggle-debugger-selected-frame
  91.      :style toggle
  92.      :selected (equal eos::debugger-frame
  93.               (selected-frame))]
  94.     "-----"
  95.     ["News..." eos::sw-news t]
  96.     )
  97.   )
  98.  
  99. (defun eos::menubar-startup ()
  100.   ;; Actions to do at startup for eos-menubar.el
  101.   (if (and (eq (device-type (selected-device)) 'x)
  102.        (or (not (local-variable-p 'current-menubar (current-buffer)))
  103.            (yes-or-no-p
  104.         "SPARCworks menu will be local (menubar is buffer-local); proceed?")))
  105.       (progn
  106.     (add-menu-button '("Help") ["SPARCworks..." eos::sw-intro t])
  107.     (add-submenu nil
  108.              (append '("SPARCworks") (copy-tree eos::short-menu))
  109.              "Version Control"
  110.              )
  111.     )))
  112.  
  113. ;;
  114. ;; Insertion of text with a font
  115. ;;
  116.  
  117. (defun eos::insert-italics (a-string)
  118.   (eos::insert-with-font a-string 'italic))
  119.  
  120. (defun eos::insert-bold (a-string)
  121.   (eos::insert-with-font a-string 'bold))
  122.  
  123. (defun eos::insert-with-font (a-string a-font)
  124.   (interactive "")
  125.   (let (a b ext)
  126.     (setq a (point))
  127.     (insert a-string)
  128.     (setq b (point))
  129.     (setq ext (make-extent a b))
  130.     (set-extent-face ext (find-face a-font))
  131.     ))
  132.  
  133. ;;
  134. ;; Generic insert code
  135. ;;
  136.  
  137. (defun eos::insert (s)
  138.   (let ((len (length s))
  139.     (pos 0)
  140.     (newpos 0)
  141.     (state 'normal))
  142.     (while (< pos len)
  143.       (setq newpos (string-match "#[bnir]" s pos))
  144.       (if (and newpos (> newpos pos))
  145.       (progn
  146.         (cond ((equal (aref s (+ newpos 1)) ?b) ; bold
  147.            (if (equal state 'normal)
  148.                (progn
  149.              (insert (substring s pos newpos))
  150.              (setq state 'bold))
  151.              (error "found bold when not in normal")))
  152.           ((equal (aref s (+ newpos 1)) ?r) ; red
  153.            (if (equal state 'normal)
  154.                (progn
  155.              (insert (substring s pos newpos))
  156.              (setq state 'red))
  157.              (error "found red when not in normal")))
  158.           ((equal (aref s (+ newpos 1)) ?i) ; italics
  159.            (if (equal state 'normal)
  160.                (progn
  161.              (insert (substring s pos newpos))
  162.              (setq state 'italics))
  163.              (error "found italics when not in normal")))
  164.           ((equal (aref s (+ newpos 1)) ?n) ; normal
  165.            (cond ((equal state 'italics)
  166.               (eos::insert-italics (substring s pos newpos))
  167.               (setq state 'normal))
  168.              ((equal state 'bold)
  169.               (eos::insert-bold (substring s pos newpos))
  170.               (setq state 'normal))
  171.              ((equal state 'normal)
  172.               (error "found normal when in normal"))))
  173.           (t
  174.            (error "internal error"))
  175.           )
  176.         (setq pos (+ newpos 2))
  177.         )
  178.     (if (equal state 'normal)
  179.         (progn
  180.           (insert (substring s pos))
  181.           (setq pos len))
  182.       (error "eos::insert with unclosed special font"))
  183.     ))
  184.     ))
  185.  
  186. ;;
  187. ;; Introduction File
  188. ;;
  189.  
  190. (defun eos::sw-intro ()
  191.   "Generate an intro buffer."
  192.   (interactive)
  193.   (let ((buffer1 (get-buffer-create " *SPARCworks Intro*"))
  194.     )
  195.     (switch-to-buffer buffer1)
  196.     (setq buffer-read-only nil)
  197.     (delete-region (point-min) (point-max))
  198.     (eos::insert "
  199.         #bSPARCworks Editor Integration#n
  200.         Eos is copyright (c) 1995 by Sun Microsystems.
  201.  
  202. #bIntroduction (for Eos 1.5.x)#n
  203.  
  204. #iSPARCworks#n is a set of integrated programming tools from SunSoft that
  205. support the program development cycle. #iXEmacs#n is a version of the Emacs
  206. editor that includes interfaces to the selection service and to the
  207. #iToolTalk#n service.  The #iEos#n package uses these two interfaces to provide
  208. a simple yet useful editor integration with three SPARCworks tools:
  209. the #iSourceBrowser#n, the #iDebugger#n and #iDbx#n.  Eos requires XEmacs 19.12
  210. or above, and SW3.0.1 or above.
  211.  
  212. When used with Eos, the Debugger and SourceBrowser do not include a
  213. source pane for displaying of sources and instead use an XEmacs frame.
  214. Then the user can interact with the XEmacs frame in a way very similar
  215. to how the source panes of the SW tools would be used.  The user can also
  216. start Dbx and request that sources be shown in XEmacs.
  217.  
  218. #bSimple Startup#n
  219.  
  220. In most cases, the user will start an interaction with Eos as follows:
  221.  
  222.  (1) Start XEmacs,
  223.  
  224.  (2) Load \"eos.el\" to add a SPARCworks submenu to the menubar (this
  225. step might not be needed if Eos is preloaded to your XEmacs binary), and
  226.  
  227.  (3) On some XEmacs frame use the SPARCworks submenu and start the
  228. desired tool and simultaneously enable that frame to display sources.
  229.  
  230. The toolbar for the enabled frame will change after (3) to show that
  231. this frame will behave as the source display for the SW tool and to
  232. indicate that some actions on the tool can be performed from this frame.
  233.  
  234. The actions available depend on the SW tool.  The interaction model for
  235. the Debugger and the SourceBrowser can be described as #iselect on the
  236. XEmacs frame and then click on the button on the SW tool#n. As an example,
  237. a browser query can be performed by selecting some text and then clicking
  238. on the query button on the SBrowser tool; the source for the first match
  239. will appear in the XEmacs frame, together with a glyph showing the match.
  240.  
  241. The Debugger and Dbx can also be driven from XEmacs.  Most frequently
  242. this will be done using the ToolBar.  Entries in the toolbar of a frame
  243. enabled for debugging are deactivated when there is not enough information
  244. to invoke their associated commands (due to technical reasons, it is
  245. necessary for XEmacs to have had a frame enabled for Debugger/Dbx when
  246. a debug or attach command was issued to Debugger/Dbx to make most toolbar
  247. commands active).  As an example, to set a breakpoint at some line, select
  248. a position in that line and then click on the toolbar icon with the stop
  249. with the arrow inside.
  250.  
  251. #bDetails#n
  252.  
  253. #iManual Startup#n
  254.  
  255. In the scenario described above, the user simultaneously starts a tool
  256. and enables a frame for that tool. The two actions can also be done
  257. independently. The tools (Source Browser, Debugger, and Dbx) have to
  258. be started with the \"-editor\" option and the XEmacs frame can be
  259. enabled manually using the SPARCworks submenu.  The most common use
  260. of this feature is to disable and re-enable a frame, be it to recover
  261. the default toolbar, or to avoid conflicts with other active tools
  262. (see the paragraph below on multiple active tools).
  263.  
  264. #iFrame Enabling#n
  265.  
  266. At any given time there can be at most one frame enabled to display
  267. Source Browser sources, and at most one frame enabled to display
  268. Debugger and Dbx sources.  The same XEmacs frame can be used for both
  269. types of sources.  The toolbar of an enabled frame always starts with
  270. an informational icon.  This icon is a large-font #ii#n with either a
  271. smaller-font #iB#n, if the frame has browsing enabled, and/or a smaller-font
  272. #iD#n, if the frame has debugging enabled.
  273.  
  274. If no frames are enabled for a given tool, the editor integration for
  275. that tool is disabled. This means that XEmacs deregisters the TT
  276. patterns relevant to this tool, and XEmacs does not receive any
  277. messages from that tool.
  278.  
  279. #iMultiple Active Tools#n
  280.  
  281. In order to provide a simpler user model, Eos has no provisions to
  282. #igracefully#n support more than one simultaneous active tool of a
  283. given class per TT session. A Debugger and a SourceBrowser, or a Dbx
  284. and a SourceBrowser, can coexist gracefully, but a Debugger and a Dbx
  285. cannot, and neither can two SourceBrowsers, two Debuggers, or two
  286. dbxs.  This simplification is consistent with the needs of most users.
  287.  
  288. The implementation of Eos notifies the user if she attempts to start two
  289. conflicting tools, but it does not enforce the restriction.  In some
  290. cases two conflicting tools can be used profitably by a careful user,
  291. but in others the result is likely to be chaos.  An example of the first
  292. is using two SourceBrowsers, and one of the later is attempting to send
  293. debugging commands from XEmacs to two debuggers.
  294.  
  295. If a user really needs to have multiple active tools, she can do this
  296. in a safe way by creating several TT sessions (e.g. using #ittsession
  297. -c /bin/csh#n, see the man page for ttsession), and placing the tools
  298. with their own XEmacses in separate TT sessions.
  299.  
  300. #iA Visual Data Inspector in XEmacs#n
  301.  
  302. Users that choose to drive the debugger from XEmacs also have
  303. available a #ivery simple#n but fast visual data inspector.  The results
  304. of #iprint#n and #iprint*#n commands are formatted into an XEmacs buffer
  305. (#i\"*Eos Print Output*\"#n) and presented into a separate frame.
  306. This frame is mapped and unmapped so that, except for the first time,
  307. it appears quickly.
  308.  
  309. #iBuffers for Debugger/Dbx Interaction#n
  310.  
  311. When starting dbx as a subprocess, a buffer will be created to interact
  312. with dbx.  The name of this buffer is of the form #i\"*Eos dbx*\"#n.
  313.  
  314. If a dbx engine is receiving requests from both Debugger and XEmacs
  315. (e.g. it was started via #idebugger -editor#n), the responses to
  316. commands sent by XEmacs will be shown in the echo area and will be
  317. recorded in a read-only buffer (#i\"*Eos Debugger Log*\"#n), but responses
  318. to Debugger commands will not appear.  Conversely, responses to Debugger
  319. commands will appear in the Debugger transcript pane but not in XEmacs's
  320. log buffer.  This is a limitation of the underlying TT protocols.
  321.  
  322. #bTTY Support#n
  323.  
  324. Although tty support is not an official part of Eos, it is possible
  325. with some extra effort and specialized knowledge from the user.
  326.  
  327. #iStarting a ToolTalk Session#n
  328.  
  329. Eos requires a ToolTalk communication.  This may require starting a TT
  330. session by:
  331.  
  332.  (0) Start a ToolTalk session, and a shell so that all processes
  333. started from this shell will use the new TT session.  Do this by
  334. executing \"ttsession -c /bin/csh\" - or whatever shell you use
  335.  
  336. At this point, you can start your XEmacs on that shell, as shown in
  337. step (1) above.  Note that, since there is no TTY toolbar in 19.12
  338. (nor 19.13), an alternative mechanism must be used to enable the
  339. (tty) frame.
  340.  
  341. A typical use for tty is to interact with dbx. The command
  342. #ieos::start-dbx#n will select the tty frame for debugging and will start
  343. a dbx buffer.  From this point on, dbx will use this tty frame to show
  344. its sources.  The introduction and news messages can be generated
  345. using the commands #ieos::sw-intro#n and #ieos::sw-news#n.  You can interact
  346. with the dbx subprocess by typing to its associated input buffer or
  347. using some key bindings.
  348.  
  349. #iKey Bindings#n
  350.  
  351. A tty user can interact with Eos by invoking directly the Eos
  352. commands, evaluating elisp expressions, or through some key-bindings.
  353. The expert user may provide her own key bindings.  Eos also provides two
  354. set of global bindings, which are activated by evaluating the
  355. expressions (eos::set-key-mode 'prefix) or (eos::set-key-mode
  356. 'function).
  357.  
  358. #bKnown Bugs#n
  359.  
  360. Due to a bug in the internal subprocess machinery of XEmacs 19.12, the
  361. default prompt of dbx subprocesses will show the full path to the binary.
  362. The prompt can be overridden using the ksh variable PS1\; one way to do
  363. this is by adding the following line to your ~/.dbxrc:
  364.  
  365.     PS1='(dbx) '
  366.  
  367. #bFeedback#n
  368.  
  369. You are encouraged to send us feedback via the Comments button in
  370. the About Box of either SPARCworks tool, or directly to
  371. eos-comments@cs.uiuc.edu.
  372.  
  373. #bEnjoy.#n")
  374.    (setq buffer-read-only t)
  375.    (goto-char (point-min))
  376.    (view-mode nil 'kill-buffer)        ;; assume the new view-less
  377.    ))
  378.  
  379. ;;
  380. ;; Cheat Sheets for keyboard mappings
  381. ;;
  382. ;; This depends on the mapping being used!
  383. ;;
  384.  
  385. (defun eos::sw-cheat-sheet ()
  386.   "Generate buffer that has a description of the key maps that can be
  387. printed, cut and then taped somewhere (like on the keyboard or on your
  388. monitor).  This is particularly useful for the function keys"
  389.   (interactive)
  390.   (let ((buffer1 (get-buffer-create " *Cheat Sheets*"))
  391.     )
  392.     (switch-to-buffer buffer1)
  393.     (setq buffer-read-only nil)
  394.     (delete-region (point-min) (point-max))
  395.     (eos::insert "
  396.         #bCheat Sheets for Eos#n
  397.  
  398. This buffer has a description of the key maps that can be printed, cut
  399. and then taped somewhere (like on the keyboard or on your monitor).
  400. This is particularly useful for the function keys since their numbers
  401. don't any particular mnemonic value.
  402.  
  403.  
  404. #bWhen using function keys#n #i[Options->SPARCworks->Use Function Keys]#n
  405.  
  406. ----------------------------------------
  407.  
  408. F6      F7        F8             F9
  409.  
  410. Do      Print     Cont    ----   Next
  411. Run     Print*    Stop   <Ctrl>  Step
  412. Fix     Dismiss   Clear  <Shft>  Step Up
  413.  
  414.  
  415. ----------------------------------------
  416.  
  417. #bWhen using prefix map#n #i[Options->SPARCworks->Use C-c d Prefix Map]#n
  418.  
  419. ----------------------------------------
  420. Basic prefix: C-c d
  421.  
  422.  
  423.     Do     %
  424.     Run     r
  425.     Fix     f
  426.  
  427.     Print     p
  428.     Print*     C-p
  429.  
  430.     Cont     c
  431.     Stop     b (for breakpoint)
  432.     Clear     C-b
  433.  
  434.     Next     n
  435.     Step     s
  436.     Step up  C-s
  437.  
  438.     Up       u
  439.     Down     d
  440. ----------------------------------------
  441.  
  442. ")
  443.    (setq buffer-read-only t)
  444.    (goto-char (point-min))
  445.    (view-mode nil 'kill-buffer)        ;; assume the new view-less
  446.    ))
  447.  
  448. ;;
  449. ;; News files
  450. ;;
  451.  
  452. (defun eos::sw-news ()
  453.   "Generate a News buffer."
  454.   (interactive)
  455.   (let ((buffer1 (get-buffer-create " *Eos News*"))
  456.     )
  457.     (switch-to-buffer buffer1)
  458.     (setq buffer-read-only nil)
  459.     (delete-region (point-min) (point-max))
  460.     (eos::insert "
  461.         #bEos News#n
  462.  
  463. See the #iHelp#n top-level menu for additional information on the
  464. SPARCworks lightweight editor integration (Eos).  The current version
  465. of Eos is available as the contents of the variable eos::version.
  466.  
  467. #bversion 1.5.2#n
  468.  
  469.     Support for 19.12 and 19.13.  Works on TTYs. Uses real ToolBar.
  470.     Toolbars for debugger & content inspector are frame-local.
  471.     Better icons and glyphs.  Support for (load-library \"eos\").
  472.     Ease-of-use: startup for tools.
  473.     Icon files are now defined \"in-line\" to simplify administration.
  474.  
  475.     Removed the following to simplify use:
  476.      - Textual toolbar (from 1.4).
  477.      - Option submenu to add keymaps for debugger use.
  478.      - Popup menu.
  479.      - Any pretenses to support SW3.0; use SW3.0.1 instead.
  480.  
  481. #bversion 1.4.1#n
  482.  
  483.     Added eos::add-button interface.
  484.  
  485. #bversion 1.4#n
  486.  
  487.     Added toolbar like in dbxtool.  Toolbar uses echo-help to show
  488.     meaning of buttons, (setq inhibit-help-echo t) if you don't
  489.     want it.
  490.  
  491.     Selection now remains after \"print\"-like commands.  Now it
  492.     is possible to have the    *debugger* buffer in the frame selected
  493.     for displaying debugged    sources.
  494.  
  495.     Added a command to relayout debugger buffers so they show in
  496.     a layout similar to that of dbxtool.
  497.  
  498. #bversion 1.3#n
  499.  
  500.     Provided popup-menu bindings for those debugger actions
  501.     that operate on the contents of the selection or its position;
  502.     selectable via options.
  503.  
  504.     The *debugger* buffer now support M-p and M-n.
  505.  
  506. #bversion 1.2#n
  507.  
  508.     Better support for interactions via *debugger* buffer and directly
  509.     using a prefix map and function keys.
  510.  
  511.     Converted to use new toggle and radio menus, reorganizing
  512.     SPARCworks menu to factor out help and options into submenus,
  513.     which are now available under the Options and Help top-level menus.
  514.  
  515. #bversion 1.1#n
  516.  
  517.     Some internal cleanup.
  518.  
  519.     Eos now provides basic machinery to drive the debugger
  520.     engine directly using ToolTalk messages.  This feature is
  521.     not yet very well polished. You can try using it at your own risk,
  522.     or await for release 1.2 (soon to come) that will provide a better
  523.     interface and improved functionality, as well as documentation
  524.     for the interface.
  525.  
  526. #bversion 1.0#n
  527.  
  528.     First widely available release.  Supports simple #iselect and click#n model.
  529.  
  530. #bPossible Future Enhancements#n
  531.  
  532. * Add a \"peek-in-source\" mechanism to show the values of
  533.   expressions in the sources.
  534.  
  535. * The comint package should be generalized to allow for TT-based
  536.   interpreters and it should be used in Eos.
  537.  
  538. * Key & popup bindings should probably be a minor mode (currently
  539.   it conflicts with cc-mode).
  540.  
  541. * Should support locking a print frame to force new print frames.  Also,
  542.   should allow for following fields in print frames.
  543.  
  544.  
  545. #bFeedback#n
  546.  
  547.     Send feedback to #ieos-comments@cs.uiuc.edu#n")
  548.    (setq buffer-read-only t)
  549.    (goto-char (point-min))
  550.    (view-mode nil 'kill-buffer)        ;; assume the new view-less
  551.    ))
  552.  
  553. (provide 'eos-menubar)
  554.  
  555. ;;; sun-eos-debugger.el ends here
  556.